package cn.com.generaldata.os.util;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.springframework.core.io.ClassPathResource;


public class CacheManager {

	//报表类型
	private Map reportTimetype = new HashMap();
	
	//BI配置
	private Map biConfig = new HashMap();
	
	public void init(){
		
		setBiConfig();	//初始化BI配置		
		
		
		setReportTimetype();
	}
	
	public void setReportTimetype(){
		reportTimetype.put("0", "月报");
		reportTimetype.put("1", "年报");
		reportTimetype.put("2", "季报");
	}
	
	public Map<String, String> getReportTimetype(){
		return reportTimetype;
	}
	
	public void setBiConfig(){
		ClassPathResource resource = new ClassPathResource("global_conf.properties");

		FileInputStream fis = null;
		try {
			fis = new FileInputStream(resource.getFile().getAbsolutePath());

			Properties properties = new Properties();
			properties.load(fis);

			List list = new ArrayList(properties.keySet());
			
			for (Object key : list){
				biConfig.put(key.toString(), new String(properties.getProperty(key.toString()).getBytes("ISO-8859-1"), "utf-8"));
			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (fis != null) {
					fis.close();
				}
			} catch (Exception e) {
			}
		}
	}
	
	public String getBiConfig(String key){
		return biConfig.get(key).toString();
	}
}
